import instance from "@/utils/http.js";
import Api from "@/api/index.js";

//获取轮播图
export const getBannerList = () => {
    return instance({
        url: Api.getBannerList,
        method: 'post',
        params: {
        }
    })
}

//获取热门视频
export const getPopularList = () => {
    return instance({
        url: Api.getPopularList,
        method: 'post',
        params: {
        }
    })
}

//获取更新时间数据
export const getRecentList = (dateTime) => {
    return instance({
        url: Api.getRecentList,
        method: 'post',
        params: {
            dateTime
        }
    })
}

//获取视频文件数据
export const getVideoFileList = (videoId) => {
    return instance({
        url: Api.getVideoFileList,
        method: 'post',
        params: {
            videoId
        }
    })
}

//获取视频详情数据
export const getVideoInfo = (videoId) => {
    return instance({
        url: Api.getVideoInfo,
        method: 'post',
        params: {
            videoId
        }
    })
}

//添加视频信息
export const addVideoInfo = data => {
    return instance({
        url: Api.addVideoInfo,
        method: 'post',
        data: {
            title: data.title,
            rating: data.rating,
            videoCover: data.videoCover,
            videoChartCover: data.videoChartCover,
            releaseDate: data.releaseDate,
            episode: data.episode,
            tags: JSON.stringify(data.tags),
            introduction: data.introduction,
            mainCharacters: JSON.stringify(data.mainCharacters),
            staff: JSON.stringify(data.staff),
            region: data.region,
            status: data.status,
            publisher: data.publisher,
            reviewStatus: data.reviewStatus
        }
    })
}

//修改视频数据
export const updateVideoInfo = (data) => {
    return instance({
        url: Api.updateVideoInfo,
        method: 'post',
        data: {
            videoId: data.videoId,
            title: data.title,
            rating: data.rating,
            videoCover: data.videoCover,
            videoChartCover: data.videoChartCover,
            releaseDate: data.releaseDate,
            episode: data.episode,
            tags: JSON.stringify(data.tags),
            introduction: data.introduction,
            mainCharacters: JSON.stringify(data.mainCharacters),
            staff: JSON.stringify(data.staff),
            region: data.region,
            status: data.status,
            publisher: data.publisher,
            reviewStatus: data.reviewStatus
        }
    })
}

// 加载数据列表
export const loadDataList = (PageSize,PageNo,title) => {
    return instance({
        url: Api.loadDataList,
        method: 'post',
        params: {
            PageSize: PageSize,
            PageNo: PageNo,
            title: title
        }
    })
}

//删除数据
export const deleteVideoInfo = (videoId) => {
    return instance({
        url: Api.deleteVideoInfo,
        method: 'post',
        params: {
            videoId: videoId
        }
    })
}

//获取视频名称列表
export const getVideoNameList = () => {
    return instance({
        url: Api.videoNameList,
        method: 'post',
        params: {}
    })
}
//获取视频文件列表
export const addVideoFile = (data) => {
    return instance({
        url: Api.addVideoFile,
        method: 'post',
        data:{
            videoId: data.videoId,
            episodeNumber: data.episodeNumber,
            videoList: data.videoList
        }
    })
}